package com.ssm.springboot.controller;

import com.ssm.springboot.pojo.DataInfo;
import com.ssm.springboot.pojo.QfTeach;
import com.ssm.springboot.service.QfTeachService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (QfTeach)表控制层
 *
 * @author makejava
 * @since 2021-12-23 15:22:59
 */
@RestController
@RequestMapping("/teach")
public class QfTeachController {
    /**
     * 服务对象
     */
    @Resource
    private QfTeachService qfTeachService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @RequiresPermissions(value = {"/teach/selectOne"})
    @RequestMapping("/selectOne")
    public DataInfo selectOne(Integer id) {
        DataInfo dataInfo = qfTeachService.queryById(id);
        return dataInfo;
    }

    @RequestMapping("/findAll")
    @RequiresPermissions(value = {"/teach/findAll"})
    public DataInfo findAll(@RequestParam("page")int page,@RequestParam("limit")int limit){
        return qfTeachService.queryAllByLimit(page,limit);
    }

    //添加教师
    @RequestMapping("/add")
    @RequiresPermissions(value = {"/teach/add"})
    public DataInfo add(@RequestBody QfTeach qfTeach){
        return  qfTeachService.insert(qfTeach);
    }

    //删除教师
    @RequiresPermissions(value = {"/teach/delete"})
    @RequestMapping("/delete")
    public DataInfo delete(int id){
        return  qfTeachService.delete(id);
    }
    //修改教师
    @RequiresPermissions(value = {"/teach/update"})
    @RequestMapping("/update")
    public DataInfo update(@RequestBody QfTeach qfTeach){
        return  qfTeachService.update(qfTeach);
    }



}